<?php

$cookie_file = dirname(__FILE__).'/cookie.txt'; 

function http_req_get($url,$params)
{
        $ch     = curl_init($url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_COOKIEJAR,  $cookie_file); //存储cookies
        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);

        $response = curl_exec($ch);
        if(curl_errno($ch))
        {
                print curl_error($ch);
        }
        curl_close($ch);
        return $response;
}

if($_SERVER['HTTP_HOST'] == 'www.baidu.com')
{
        //铁通119.75.217.56
        //联通61.135.169.105
        if(empty($_SERVER['QUERY_STRING']))
        {
                include("./socket.request.php");
                $homepage = httpRequest('61.135.169.105', 'www.baidu.com' ,'/');
                // $homepage = http_req_get("http://119.75.217.56/");
                $homepage = str_replace('http://www.baidu.com/img/bdlogo.gif','http://61.135.169.105/img/bdlogo.gif',$homepage);
                echo $homepage;
        }
        else
        {
                $homepage = http_req_get("http://61.135.169.105".$_SERVER['REQUEST_URI']);
                $ad = '<div id="content_left"><div style="background:#fff8e7;padding:5px;margin-bottom:10px;height:100px;"><h1>&nbsp;我是不会告诉你如何注入的！！</h1></div>';
                $homepage = str_replace('<div id="content_left">',$ad,$homepage);
                echo $homepage;        
        }
}
else if($_SERVER['HTTP_HOST'] == 'www.so.com')
{
        if(empty($_SERVER['QUERY_STRING']))
        {
                echo file_get_contents("./www.so.com.html");
        }
        else
        {
                $homepage = http_req_get("http://106.120.160.134/s?".$_SERVER['QUERY_STRING']);
                $ad = '<div id="main"><div style="background:#fff8e7;padding:5px;margin-bottom:10px;height:100px;"><h1>&nbsp;我是不会告诉你如何注入的！！</h1></div>';
                $homepage = str_replace('<div id="main">',$ad,$homepage);
                echo $homepage;        
        }  
}

else if($_SERVER['HTTP_HOST'] == 'mp.weixin.qq.com')
{
        include("./socket.request.php");
        //182.254.10.58 铁通
        //140.206.160.199 联通
        $homepage = httpRequest('140.206.160.199', 'mp.weixin.qq.com' ,$_SERVER['REQUEST_URI']);
        $ad = '<div id="page-content" class="page-content"><div style="background:#fff8e7;padding:5px;margin-bottom:10px;height:100px;"><h1>&nbsp;我是不会告诉你如何注入的！！</h1></div>';
        $homepage = str_replace('<div id="page-content" class="page-content">',$ad,$homepage);
        echo $homepage;
}
?>